x
this.parent.remove(this); var appendLast = !nodeList.length || node.name > nodeList[nodeList.length - 1].name; if (appendLast) { nodeList.push(node); if (forceRerootingEvenIfOrdered) this.li.insertBefore(node.li, insertBeforeElement); return; }​ if (node.name < nodeList[0].name) { // goes at the head of the list nodeList.unshift(node); this.li.insertBefore(nodeList[0].li); return; } // binary search var loIndex = 1; // inclusive var hiIndex = nodeList.length - 2; // inclusive while (hiIndex - loIndex > 1) { var midIndex = loIndex + (((hiIndex - loIndex) / 2) | 0); var midNode = nodeList[midIndex]; if (name > midNode.name) { loIndex = midIndex + 1; // inclusive } else { hiIndex = midIndex - 1; // inclusive } }​ this.li.insertBefore(node.li, nodeList[hiIndex].li); nodeList.splice(hiIndex, 0, node); } }​ export function normalizePath(path: string) : string { return path; }}